package test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.util.UrlPathHelper;
import test.annotation.ServiceConfig;
import test.context.JsonContext;
import test.in.EsbIn;
import test.vo.UserVO;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : example
 * @ Author: XuLeHuang
 * @ Date: 2022/11/16 22:22
 * @ Description:
 */
@Controller
public class GateWayController {

    @RequestMapping(value = "1d01esb" , method = RequestMethod.POST)
    @ServiceConfig(value = EsbIn.class , originalPath = "/1d01" , flow = "DefaultFlow" , channel = "esb")
    @ResponseBody
    public Object svc_1d01(@RequestBody UserVO userVO , JsonContext jsonContext ,HttpServletRequest request) {
        String requestURI = request.getRequestURI();
        StringBuffer requestURL = request.getRequestURL();
        System.out.println("leave 1d01esb");
        return jsonContext.getRspJsonObject();
    };

    @RequestMapping(value = "1d02esb" , method = RequestMethod.GET)
    @ServiceConfig(value = EsbIn.class , originalPath = "/1d02" , flow = "DefaultFlow" , channel = "esb")
    @ResponseBody
    public String svc_1d02() {
        HttpServletRequest requestAttributes = (HttpServletRequest) RequestContextHolder.getRequestAttributes();
        String id = UrlPathHelper.getResolvedLookupPath(requestAttributes);
        System.out.println(id);
        System.out.println("leave 1d02esb");
        return null;
    };
}
